#include "logindialog.h"
#include "ui_logindialog.h"

LoginDialog::LoginDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LoginDialog)
{
    ui->setupUi(this);
    this->setAttribute(Qt::WA_DeleteOnClose);
    this->setWindowFlags(Qt::SplashScreen | Qt::FramelessWindowHint);
    this->setWindowIcon(QIcon(":/icon/alarm.ico"));
    this->setWindowTitle("闹钟");
    this->setMouseTracking(true);
}

LoginDialog::~LoginDialog()
{
    delete ui;
}

void LoginDialog::on_pushButton_clicked()
{
    if (ui->lineEdit->text() == "admin" && ui->lineEdit_2->text() == "123") {
        this->accept();
    }
}


void LoginDialog::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton) {
        moving = true;
        lastPoint = event->globalPos() - pos();
    }

    //return LoginDialog::mousePressEvent(event);
}

void LoginDialog::mouseReleaseEvent(QMouseEvent *event)
{
    moving = false;
}

void LoginDialog::mouseMoveEvent(QMouseEvent *event)
{
    if (moving && (event->buttons()) &&
            (event->globalPos() - lastPoint).manhattanLength() > QApplication::startDragDistance()) {
        move(event->globalPos() - lastPoint);
        lastPoint = event->globalPos() - pos();
    }

    //return LoginDialog::mouseMoveEvent(event);
}
